from selenium import webdriver
from selenium.webdriver.common.by import By
import time

#登陆成功
driver = webdriver.Chrome()

driver.get('http://localhost:90/')

driver.maximize_window()


driver.find_element(By.ID, 'username').send_keys('丁真')
time.sleep(2)
driver.find_element(By.ID, 'password').send_keys('123456')
time.sleep(2)
driver.find_element(By.ID, 'login_btn').click()


re = driver.find_element(By.XPATH, '//*[@id="topbarheader"]/nav/div/ul/li[1]/a/span').text
# print(re)
if re == '丁真':
    driver.save_screenshot('success.png')
    print('测试成功')
else:
    driver.save_screenshot('error.png')
time.sleep(5)

driver.quit()

#登陆失败
# driver = webdriver.Chrome()
#
# driver.get('http://localhost:90/')
#
# driver.maximize_window()
#
# driver.find_element(By.ID, 'username').send_keys('依然范小勤')
# time.sleep(2)
# driver.find_element(By.ID, 'password').send_keys('123456')
# time.sleep(2)
# driver.find_element(By.ID, 'login_btn').click()
#
#
# re = driver.title
# if re == '后台管理系统':
#     print('测试成功')
# else:
#     print('测试失败')
#     driver.save_screenshot('error.png')
# time.sleep(5)
#
# driver.quit()

# 注册成功
# driver = webdriver.Chrome()
#
# driver.get('http://localhost:90/')
#
# driver.maximize_window()
#
# time.sleep(2)
# driver.find_element(By.LINK_TEXT, '还没有账号？去注册').click()
# time.sleep(2)
# driver.find_element(By.ID, 'username').send_keys('依然范小勤')
# time.sleep(2)
# driver.find_element(By.ID, 'password').send_keys('666666')
# time.sleep(2)
# driver.find_element(By.ID, 'repassword').send_keys('666666')
# time.sleep(2)
# driver.find_element(By.ID, 'login_btn').click()
# # time.sleep(5)
# re = driver.title
# if re == '度小满理财-登录[内测版]':
#     driver.save_screenshot('success1.png')
#     print('测试成功')
# else:
#     print('测试失败')
# time.sleep(5)
#
# driver.quit()

#注册失败
# driver = webdriver.Chrome()
#
# driver.get('http://localhost:90/')
#
# driver.maximize_window()
#
# time.sleep(2)
# driver.find_element(By.LINK_TEXT, '还没有账号？去注册').click()
# time.sleep(2)
# driver.find_element(By.ID, 'username').send_keys('依然范小勤')
# time.sleep(2)
# driver.find_element(By.ID, 'password').send_keys('666666')
# time.sleep(2)
# driver.find_element(By.ID, 'repassword').send_keys('111111')
# time.sleep(2)
# driver.find_element(By.XPATH, '/html/body/div/div/div/div[1]/h1').click()
# time.sleep(2)
# driver.find_element(By.ID, 'login_btn').click()
# # time.sleep(5)
# re = driver.title
# if re == '度小满理财-登录[内测版]':
#     # driver.save_screenshot('success1.png')
#     print('测试成功')
# else:
#     driver.save_screenshot('error1.png')
#     print('测试失败')
# time.sleep(5)
#
# driver.quit()

#网贷成功
# driver = webdriver.Chrome()
#
# driver.get('http://localhost:90/')
#
# driver.maximize_window()
#
#
# driver.find_element(By.ID, 'username').send_keys('丁真')
# time.sleep(2)
# driver.find_element(By.ID, 'password').send_keys('123456')
# time.sleep(2)
# driver.find_element(By.ID, 'login_btn').click()
# driver.implicitly_wait(5)
# driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[3]/a').click()
# time.sleep(2)
# driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[3]/ul/li[2]/a').click()
# time.sleep(2)
# driver.find_element(By.ID, 'amount').send_keys(11111)
# time.sleep(2)
# driver.find_element(By.ID, 'term').send_keys(60)
# time.sleep(2)
# driver.find_element(By.ID, 'submit').click()
# driver.implicitly_wait(5)
# driver.find_element(By.XPATH, '/html/body/div[2]/div[2]/div/div/div/div/div/div/div/div[4]/button[1]').click()
# time.sleep(0.2)
# driver.save_screenshot('success2.png')
# print('申请成功')
# driver.quit()

#网贷失败
# driver = webdriver.Chrome()
#
# driver.get('http://localhost:90/')
#
# driver.maximize_window()
#
#
# driver.find_element(By.ID, 'username').send_keys('丁真')
# time.sleep(2)
# driver.find_element(By.ID, 'password').send_keys('123456')
# time.sleep(2)
# driver.find_element(By.ID, 'login_btn').click()
# driver.implicitly_wait(5)
# driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[3]/a').click()
# time.sleep(2)
# driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[3]/ul/li[2]/a').click()
# time.sleep(2)
# driver.find_element(By.ID, 'amount').send_keys(1000000000)
# time.sleep(2)
# driver.find_element(By.ID, 'term').send_keys(9999)
# time.sleep(2)
# driver.find_element(By.ID, 'submit').click()
# driver.implicitly_wait(5)
# driver.find_element(By.XPATH, '/html/body/div[2]/div[2]/div/div/div/div/div/div/div/div[4]/button[1]').click()
# time.sleep(2)
# driver.save_screenshot('error2.png')
# time.sleep(5)
# print('申请失败')
# driver.quit()